﻿/*
 * modbustcp.cpp
 *
 *  Created on: 2017年10月30日
 *      Author: work
 */

#include <dm/export.hpp>

#define DM_API_PROTOCOL DM_API_EXPORT

#include <dm/protocol/modbustcp.hpp>
#include <dm/os/log/logger.hpp>

namespace dm{
namespace protocol{

static const char* logModule = "CModbusTcp.protocol.dm";

CModbusTcp::CModbusTcp():CProtocol(),m_rxFrame(NULL),m_txFrame(NULL){
	log().debug(THISMODULE "创建对象");
}

CModbusTcp::~CModbusTcp(){
	log().debug(THISMODULE "销毁对象");
	if( !m_rxFrame )
		delete m_rxFrame;
	if( !m_txFrame )
		delete m_txFrame;
}

const dm::protocol::CFrame& CModbusTcp::getTxFrame(){
	if( !m_txFrame )
		m_txFrame = genTxTempFrame();
	return *m_txFrame;
}

dm::protocol::CFrame& CModbusTcp::getRxFrame(){
	if( !m_rxFrame )
		m_rxFrame = genRxTempFrame();
	return *m_rxFrame;
}

}
}


